package model;
import java.util.ArrayList;
import java.io.*;

public class Activity {
    
    ArrayList<Edge> _edges = new ArrayList<Edge>();
    Node _node;
    Edge _edge;
    
    String _name;
    String _stateChanges;
    String _nodeDescription;
    String _parameters;
    
    String _edgeDescription;
    String _endNodeName;
    String _condition;
    String _delay;
    String _priority;
    String _attributes;
    
    public Activity(int ID, String description) {
        makeStartNode(ID, description);
        makeFinishNode(ID, description);
    }
    
    public void makeStartNode(int ID, String description) {
        /*
         * Make the node
         */
        _name = "ACT" + ID + "_START";
        _nodeDescription = description;
        _stateChanges = "ENT[5]=0,STAFF=STAFF+PUT{INC;ENT[5]}";  //This is a custom code
        _parameters = "ENT[0],ENT[1],ENT[2],ENT[3],ENT[4]";
        
        _node = new Node(_name, _nodeDescription, _stateChanges, _parameters);
        
        /*
         * Make the edges
         */
        
        _edgeDescription = "";
        _endNodeName = "ACT" + ID + "_FINISH";
        _condition = "1==1";
        _delay = "DISK{PROCEDURE.DAT;(PRDDATA+1)*" + ID + "+2}";
        _priority = "";
        _attributes = "ENT[0],ENT[1],ENT[2],ENT[3],ENT[4]+1";
        
        _edge = new Edge(_edgeDescription, _name, _endNodeName, _condition, _delay, _priority, _attributes);
        _edges.add(_edge);
    }
    
    public void makeFinishNode(int ID, String description) {
        /*
         * Make the node
         */
        _name = "ACT" + ID + "_FINISH";
        _nodeDescription = description;
        _stateChanges = "STAFF=STAFF-1, QPRD[" + ID + "]=QPRD[" + ID + "]-GET{FST;" + ID + "}";
        
        _node = new Node(_name, _nodeDescription, _stateChanges, _parameters);
        
        /*
         * _LEAVE -> SORT
         */
        _edgeDescription = "";
        _endNodeName = "SORT";
        _condition = "1==1";
        _delay = "0";
        _priority = "";
        _attributes = "ENT[5]";
        
        _edge = new Edge(_edgeDescription, _name, _endNodeName, _condition, _delay, _priority, _attributes);
        _edges.add(_edge);
        
        /*
         * _LEAVE -> _START
         */
        _edgeDescription = "";
        _name = "P" + ID + "_START";
        _condition = "QPRD[" + ID + "]>0";
        _delay = "0";
        _priority = "";
        _attributes = "";
        
        _edge = new Edge(_edgeDescription, _name, _endNodeName, _condition, _delay, _priority, _attributes);
        _edges.add(_edge);
        
    }
    
    public void outputNode() {
        
    }
    
    public void outputEdge() {
        
    }
}
